package com.ttwl.www.app.homepage;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.ttwl.www.app.R;

public class FreeActivity extends AppCompatActivity {

    private RecyclerView mFree;

    @SuppressLint("WrongViewCast")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_free);

        mFree = (RecyclerView) findViewById(R.id.free);
        mFree.setLayoutManager(new LinearLayoutManager(FreeActivity.this));
//        这个方法可以实现分割线，不仅限于设置分割线
        mFree.addItemDecoration(new MyDecoration());
        mFree.setAdapter(new FreeAdapter(FreeActivity.this));
    }

    class MyDecoration extends RecyclerView.ItemDecoration {
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);
            outRect.set(0,0,0,getResources().getDimensionPixelOffset(R.dimen.dividerHeight));
        }
    }
}
